package com.tbit.uqbike.service.business.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tbit.uqbike.annos.EncapsulateMap;
import com.tbit.uqbike.object.pojo.RechargeGiveLog;
import com.tbit.uqbike.object.value.Page;
import com.tbit.uqbike.service.business.RechargeGiveLogService;
import com.tbit.uqbike.webmanager.dao.log.RechargeGiveLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jing
 * @date 2020/11/1013:52
 * @Description:
 */
@Service("rechargeGiveLogService")
public class RechargeGiveLogServiceImpl implements RechargeGiveLogService {
    @Autowired
    private RechargeGiveLogDao rechargeGiveLogDao;

    /**
     * @param params
     * @param accountId
     * @param startTime
     * @param endTime
     * @param flag      true统计赠送钱，false统计赠送优惠券
     * @param moneys
     * @param page
     * @return java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
     * @Description:
     * @createDate 2020/12/22 9:56
     */
    @Override
    @EncapsulateMap
    public List<Map<String, Object>> getByType(HashMap<String, Object> params, Integer accountId, Date startTime, Date endTime, Boolean flag, List<Integer> moneys, Page page) {
//        PageHelper.startPage(page.getPageNO(),page.getRowCount());
        return rechargeGiveLogDao.selectByRechargeMoney(params);
    }

    @Override
    public PageInfo<RechargeGiveLog> getRechargeGiveLog(RechargeGiveLog give, Page page) {
        if (null != page) {
            PageHelper.startPage(page.getPageNO(), page.getRowCount());
        }
        List<RechargeGiveLog> giveLogs = rechargeGiveLogDao.selectRechargeGiveLog(give);
        PageInfo<RechargeGiveLog> pageInfo = new PageInfo<>(giveLogs);
        return pageInfo;

    }

    @Override
    public Map<String, Object> getTotal(RechargeGiveLog rechargeGiveLog) {
        Map<String, Object> map = new HashMap<>();
        map.put("accountId", rechargeGiveLog.getAccountId());
        map.put("startTime", rechargeGiveLog.getStartTime());
        map.put("endTime", rechargeGiveLog.getEndTime());
        return rechargeGiveLogDao.getTotal(map);
    }

}
